/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package action.paypal;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;

/**
 *
 * @author Thai Ha Cong
 */
@Namespace("/Administration")
public class PaypalNotifyAction extends ActionSupport {

    public PaypalNotifyAction() {
    }

    @Override
    @Action(value = "paypalNotify", results = {
        @Result(name = "success", location = "/administration/paypalNotify.jsp"),
        @Result(name = "input", location = "/administration/paypalNotify.jsp")
    })
    public String execute() throws Exception {
        //HttpServletRequest request = ServletActionContext.getRequest();
        //String mcg = request.getParameter("mc_gross");
        //System.out.println("---" + mcg + "---");
        String out = "";

        Map parametersMap = ActionContext.getContext().getParameters();
//        Iterator iterator = parametersMap.entrySet().iterator();
//        
//        while (iterator.hasNext()) {
//            Map.Entry mapEntry = (Map.Entry) iterator.next();
//            String key = (String) mapEntry.getKey();
//            String[] value = (String[]) mapEntry.getValue();
//            
//            System.out.println("Key: " + key + " - Value: " + value[0]);
//            out = out + "Key: " + key + " - Value: " + value[0] + "<br>";
//        }

        if (parametersMap.containsKey("token")) {
            out = out + "token: " + Arrays.toString((String[]) parametersMap.get("token")) + "<br>";
        }



        addActionMessage(out);
        return SUCCESS;
    }
}